package com.thy.task;

import com.thy.controller.UController;
import com.thy.util.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component("userTask")
//@Async
public class UserTask {

    @Autowired
    UController userController;

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    //每隔半分钟执行一次
    //@Scheduled(cron = "30 */1 * * * ?")
    public void sendMessage(){
        logger.info("定时任务开启,当前时间为:"+ DateUtil.format(new Date(),DateUtil.DATE_TIME_PATTERN));
        userController.sendMess();
        logger.info("定时任务结束,当前时间为:"+ DateUtil.format(new Date(),DateUtil.DATE_TIME_PATTERN));
    }
}
